package model

type ESGoods struct {
	ID         int32 `json:"id"`
	CategoryID int32 `json:"category_id"`
	BrandsID   int32 `json:"brands_id"`
	OnSale     bool  `json:"on_sale"`
	ShipFree   bool  `json:"ship_free"`
	IsNew      bool  `json:"is_new"`
	IsHot      bool  `json:"is_hot"`

	Name        string `json:"name"`
	ClickNum    int32  `json:"click_num"`
	SoldNum     int32  `json:"sold_num"`
	FavNum      int32  `json:"fav_num"`
	MarketPrice int32  `json:"market_price"`
	GoodsBrief  string `json:"goods_brief"`
	ShopPrice   int32  `json:"shop_price"`
}

func (ESGoods) GetIndexName() string {
	return "goods"
}

type H map[string]interface{}

func (ESGoods) GetMapping() map[string]interface{} {
	return H{
		"mappings": H{
			"properties": H{
				"brands_id": H{
					"type": "integer",
				},
				"category_id": H{
					"type": "integer",
				},
				"click_num": H{
					"type": "integer",
				},
				"fav_num": H{
					"type": "integer",
				},
				"id": H{
					"type": "integer",
				},
				"is_hot": H{
					"type": "boolean",
				},
				"is_new": H{
					"type": "boolean",
				},
				"market_price": H{
					"type": "float",
				},
				"name": H{
					"type":     "text",
					"analyzer": "ik_max_word",
				},
				"goods_brief": H{
					"type":     "text",
					"analyzer": "ik_max_word",
				},
				"on_sale": H{
					"type": "boolean",
				},
				"ship_free": H{
					"type": "boolean",
				},
				"shop_price": H{
					"type": "float",
				},
				"sold_num": H{
					"type": "long",
				},
			},
		},
	}
}
